package com.jungle.mvvm.update;


import com.jungle.mvvm.http.download.DownLoadSubscriber;
import com.jungle.mvvm.http.download.ProgressCallBack;

/**
 * @ClassName MyDownLoadSubscriber
 * @Description MyDownLoadSubscriber
 * @Author Daniel
 * @Version V1.0.0
 */
public class MyDownLoadSubscriber<T> extends DownLoadSubscriber<T> {
    private String downloadId = "";

    public MyDownLoadSubscriber(ProgressCallBack fileCallBack) {
        super(fileCallBack);
        downloadId = System.currentTimeMillis() + "";
    }

    @Override
    public void onStart() {
        super.onStart();
        DownLoadHelper.getInstance().getDownLoadSubscribers().put(downloadId, this);
    }

    @Override
    public void onComplete() {
        super.onComplete();
        DownLoadHelper.getInstance().getDownLoadSubscribers().remove(downloadId);
    }

    @Override
    public void onError(Throwable e) {
        super.onError(e);
        DownLoadHelper.getInstance().getDownLoadSubscribers().remove(downloadId);
    }

    @Override
    public void onNext(T t) {
        super.onNext(t);
    }

    public String getDownloadId() {
        return downloadId;
    }

    public void setDownloadId(String downloadId) {
        this.downloadId = downloadId;
    }
}
